/** version: 1.3.0 */ var f=(t,a,e)=>{if(!a.has(t))throw TypeError("Cannot "+e)};var g=(t,a,e)=>(f(t,a,"read from private field"),e?e.call(t):a.get(t)),p=(t,a,e)=>{if(a.has(t))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(t):a.set(t,e)},u=(t,a,e,r)=>(f(t,a,"write to private field"),r?r.call(t,e):a.set(t,e),e);function C(t){const a=Object.entries(t).reduce((e,[r,s])=>{if(s!==void 0){const o=Array.isArray(s)?s.join(","):typeof s=="string"?s:String(s);e.push([r,o])}return e},[]);return new URLSearchParams(a)}function x(t,a,e){const r=a.startsWith("/")?a:`/${a}`,s=new URL(r,t);return e&&(s.search=e.toString()),s.toString()}const y=new Map;function T(t){const a=JSON.stringify(t),e=y.get(a);if(e)return e;const r=t.queryParams?C(t.queryParams):void 0,s=x(window.galaxyInfo.proxy_url,t.path,r),o=S({url:s,headers:{"x-galaxy-key":window.galaxyInfo.proxy_key}});return y.set(a,o),o}async function S(t){const a=await fetch(t.url,{method:"GET",headers:{...t.headers}});if(!a.ok){const r=await a.json();throw new Error(`HTTP error! status: ${a.status}. Check devtools "Network" tab to see more details about this failing call. ${JSON.stringify(r,null," ")}`)}return await a.json()}const v=3*60*1e3;let c,i;const w=()=>{if(c!==void 0)return c;try{const a=JSON.parse(sessionStorage.getItem("gms_profil_data")??"{}").tierCode;return c=typeof a=="string"?a:void 0,i&&window.clearTimeout(i),i=window.setTimeout(()=>{b()},v),c}catch(t){console.error("getMemberTier error",t);return}},b=()=>{c=void 0,i&&(window.clearTimeout(i),i=void 0)},A=["config","data-state"];var l;class R extends HTMLElement{constructor(){super();p(this,l,!1);this.updateRateForUser=this.updateRateForUser.bind(this)}static get observedAttributes(){return A}setLoadingUiState(e){this.setAttribute("data-state",e)}removeComponent(){this.setAttribute("data-empty","true")}connectedCallback(){this.initLazyLoading()}cleanIfHasNoFallback(){var r;const e=this.querySelector("glx-tc-lead-rate-value");(!e||!((r=e.textContent)!=null&&r.trim().length))&&this.removeComponent()}appendChildLeadRateComponent(e,r,s=!1){const o=this.querySelector(e);o&&(o.innerHTML=r,s&&o.setAttribute("data-has-member-rate","true"))}initLazyLoading(){const e={root:null,rootMargin:"700px"};new IntersectionObserver((r,s)=>{r[0].isIntersecting&&(this.fetchAndProcess(),s.unobserve(this))},e).observe(this)}updateRateForUser(){g(this,l)&&this.fetchAndProcess()}fetchAndProcess(){u(this,l,!0);const e=this.getAttribute("config");if(e){this.setLoadingUiState("loading");const r=JSON.parse(e),s=r.hotelCodes,o=w(),m={daysAhead:r.daysAhead,roomTypeCodes:r.roomTypeCodes?[r.roomTypeCodes]:void 0,legacyDisplay:!0,adults:r.adults,memberTier:o};T({path:`/tc/shop/v1/hotel/${s}/leadrate`,queryParams:m}).then(d=>{var h;const n=d[0];n.available?(n.minRateDisplay&&this.appendChildLeadRateComponent("glx-tc-lead-rate-value",n.minRateDisplay,!!((h=n.memberMinRateDisplay)!=null&&h.length)),n.memberMinRateDisplay&&this.appendChildLeadRateComponent("glx-tc-lead-rate-member-value",n.memberMinRateDisplay),n.strikeThroughRateDisplay&&this.appendChildLeadRateComponent("glx-tc-lead-rate-strike-value",n.strikeThroughRateDisplay)):(console.debug(`[rate-proxy] API Lead rate does not return rate for: ${JSON.stringify({hotel:s,room:m.roomTypeCodes})}. Component will use fallback value if available`),this.cleanIfHasNoFallback())}).catch(d=>{throw this.cleanIfHasNoFallback(),new Error(d)}).finally(()=>this.setLoadingUiState("ready"))}else this.setLoadingUiState("ready"),this.cleanIfHasNoFallback()}disconnectedCallback(){u(this,l,!1)}}l=new WeakMap;class E extends HTMLElement{constructor(){super()}}class M extends HTMLElement{constructor(){super()}}class k extends HTMLElement{constructor(){super()}}customElements.define("glx-tc-lead-rate",R);customElements.define("glx-tc-lead-rate-value",M);customElements.define("glx-tc-lead-rate-member-value",E);customElements.define("glx-tc-lead-rate-strike-value",k);function L(){if(b(),!!!document.querySelector("glx-tc-lead-rate-member-value"))return;document.querySelectorAll("glx-tc-lead-rate").forEach(e=>{e instanceof R&&e.updateRateForUser()})}document.addEventListener("EVT_AMA_HOS_GMS_LOGIN",L);document.addEventListener("EVT_AMA_HOS_GMS_LOGOUT",L);